<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\GrowthStandard;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class GrowthStandardController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new GrowthStandard(), function (Grid $grid) {
            $grid->column('month_name');
            $grid->column('p3');
            $grid->column('p50');
            $grid->column('p97');
            $grid->column('type')->using([1=>'体重',2=>'身高']);
            $grid->column('gender')->using([1=>'男',2=>"女"]);

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('type','类型')->select([1=>'体重',2=>'身高']);
                $filter->equal('gender','性别')->select([1=>'男',2=>'女']);


            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new GrowthStandard(), function (Show $show) {
            $show->field('id');
            $show->field('month');
            $show->field('month_name');
            $show->field('p3');
            $show->field('p97');
            $show->field('type');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {


        return Form::make(new GrowthStandard(), function (Form $form) {
            $form->display('id');
            $form->text('month');
            $form->text('month_name');
            $form->text('p3');
            $form->text('p50');
            $form->text('p97');
            $form->radio('gender')->options([1=>'男',2=>"女"]);

            $form->radio('type')->options([1=>'体重',2=>'身高']);
        });
    }
}
